package com.zhangqiang.git.cloud.consumer.controller;

import com.zhangqiang.git.cloud.domain.consumer.SysUser;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.ArrayList;
import java.util.List;
import java.util.UUID;

@RestController
@RequestMapping("/consumer")
public class ConsumerController {

    @PostMapping("/findUserByName")
    public SysUser findUserByName(@RequestParam("username") String name){

        if(!"admin".equals(name)){
            return null;
        }

        SysUser user = new SysUser();
        user.setUserId(UUID.randomUUID().toString());
        user.setUserName(name);
        user.setPassword(name+"123");

        return user;
    }

    @PostMapping("/findRolesByUser")
    public List<String> findRolesByUser(@RequestParam("username") String userId){
        List<String> roles = new ArrayList<>();
        roles.add("producer1_project_name");
        return roles;
    }





}
